<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>激活课程卡</title>
    <link rel="shortcut icon" href="${siteCompany.ico!'/static/favicon.ico'}" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="/static/css/public.css" />
    <link rel="stylesheet" type="text/css" href="/static/libs/layui-v2.6.8/css/layui.css" />
    <script type="text/javascript" src="/static/libs/jquery/jquery-3.6.0.min.js"></script>
    <script type="text/javascript" src="/static/libs/layui-v2.6.8/layui.js"></script>
</head>
<body>
<div class="layui-container">
    <form class="layui-form pt30" onsubmit="return false;" lay-filter="example">
        <div class="layui-form-item layui-row">
            <label class="layui-form-label required">卡号</label>
            <div class="layui-input-block layui-col-md8">
                <input type="text" name="cardCode" id="cardCode" placeholder="卡号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">密码</label>
            <div class="layui-input-block">
                <input type="text" name="cardPassword" id="cardPassword" placeholder="密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">&nbsp;</label>
            <div class="layui-input-block">
                <input class="layui-btn layui-btn-normal" type="button" value="激 活" id="btn-active">
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        $('#btn-active').click(function (){
            var cardCode = $("#cardCode").val();
            var cardCodePassword = $("#cardPassword").val();
            if (cardCode === '') {
                return layer.msg("卡号不能为空！");
            }
            if (cardCodePassword === '') {
                return layer.msg("密码不能为空！");
            }
            $.ajax({
                url: "/user/course/card/active.json",
                data: {
                    "type": 1,
                    "cardCode": $.trim(cardCode),
                    "cardCodePassword": $.trim(cardCodePassword)
                },
                type: "post",
                dataType: "json",
                cache: false,
                success: function (result) {
                    if (result.code === 0) {
                        return layer.alert("您的课程卡已激活成功!", function () {
                            parent.location.reload();
                        });
                    } else {
                        return layer.msg(result.msg);
                    }
                },
                error: function (error) {
                    return layer.msg("您的课程卡激活发生异常，请及时联系客服人员进行处理，谢谢！");
                }
            });
        })
    });
</script>
</body>
</html>